container_aria

my file learn about tech container (docker, podman, kubernetes)


Project maintained by ariafatah0711 Hosted on GitHub Pages — Theme by mattgraham

ansible inventory

plugin pada inventory

1

[inventory]
enable_plugins = host_list, script, auto, yaml, ini, toml

2

[inventory]
enable_plugins = host_list, script, auto, yaml, ini, toml, namespace.collection_name.inventory_plugin_name

3

[inventory]
enable_plugins = host_list, script, auto, yaml, ini, toml, my_plugin

membuat ansible inventory

cat > inventory << EOF
node1 # ip 1
node2 # ip 
EOF

ansible node1 -m ping
# [WARNING]: No inventory was parsed, only implicit localhost is available
# [WARNING]: provided hosts list is empty, only localhost is available. Note that the
# implicit localhost does not match 'all'
# [WARNING]: Could not match supplied host pattern, ignoring: node1

hirarki pembacaan inventory

ansible node1 -i inventory -m ping
node1 | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python3"
    },
    "changed": false,
    "ping": "pong"
}

menggunakan ssh key di inventory

node1 ansible_user=root ansible_ssh_private_key_file=~/.ssh/id_rsa
node2 ansible_user=root ansible_ssh_private_key_file=/ssh_node2/private.key

membuat group name dan groups variables

ex 1

mail.example.com

[webservers]
foo.example.com
bar.example.com

[dbservers]
one.example.com
two.example.com
three.example.com

ex 2

[atlanta]
host1
host2

[atlanta:vars]
ntp_server=ntp.atlanta.example.com
proxy=proxy.atlanta.example.com

example

[node_docker]
node1
node2
node3

[node_docker:vars]
ansible_user=root
ansible_ssh_private_key_file=/ssh_node/private.key

run

ansible node1 -i 03\ -\ inventory_group_var -m ping
# node1 | SUCCESS => {}

pattern

ansible <pattern> -m <module_name> -a "<module options>"

ansible node_docker -i 03\ -\ inventory_group_var -m ping
# node1 | SUCCESS => {}
# node2 | SUCCESS => {}
# node3 | SUCCESS => {}